import React, { useEffect, useMemo, useState } from "react";
import styles from "./Index.module.css";
import { Avatar } from "antd-mobile";
import instance from "../../api/request";
import { useNavigate, useParams, useSearchParams } from "react-router-dom";
function Index() {
  const { id } = useParams();
  const [data, setData] = useState([]);
  const [sp]=useSearchParams()
  const spObj=useMemo(()=>Object.fromEntries(sp),[sp])
  const nav=useNavigate()

  const getday = () => {
    instance
      .get("/api/share/knowledgeBase/v1/findDiseaseKnowledge", {
        params: {
          id: id,
        },
      })
      .then((res) => {
        console.log(res);
        setData(res.data.result)
      });
  };

  useEffect(() => {
    getday();
  }, [id]);

  return (
    <div className={styles.zong}>
      <div className={styles.heard}>
        <div className={styles.wen} onClick={()=>nav('/person')}>
          <Avatar src="" style={{ "--border-radius": "50%" }} />
        </div>


        <div className={styles.icon}>
          <img src="/heil.png" alt="" />
        </div>
      </div>


      <div className={styles.hong}>
        本模块知识仅供参考，如有需要，请在医生指导下使用
      </div>
      

      <div className={styles.wenz}>
        <h2>{spObj.title}</h2>

        <span>
            <b style={{color:'#81b6f3'}}>[病理]</b>
            <p>{data.benefitTaboo && data.benefitTaboo.length>0 ? <span>{data.benefitTaboo}</span> : <span>无</span>}</p>
        </span>
         <span>
            <b style={{color:'#81b6f3'}}>[症状]</b>
            <p>{data.chineseMedicineTreatment && data.chineseMedicineTreatment.length>0 ? <span>{data.chineseMedicineTreatment}</span> : <span>无</span>}</p>
        </span>

         <span>
            <b style={{color:'#81b6f3'}}>[宜与忌]</b>
            <p>{data.pathology && data.pathology.length>0 ? <span>{data.pathology}</span> : <span>无</span>}</p>
        </span>


          <span>
            <b style={{color:'#81b6f3'}}>[西药治疗]</b>
            <p>{data.symptom && data.symptom.length>0 ? <span>{data.symptom}</span> : <span>无</span>}</p>
        </span>

         <span>
            <b style={{color:'#81b6f3'}}>[中药治疗]</b>
            <p>{data.westernMedicineTreatment && data.westernMedicineTreatment.length>0 ? <span>{data.westernMedicineTreatment}</span> : <span>无</span>}</p>
        </span>
        
        
      </div>
    </div>
  );
}

export default Index;
